<template>
  <div class="video-center">
    <!-- 顶部横幅 -->
    <div class="hero-section">
      <div class="hero-content">
        <h1 class="hero-title">视频中心</h1>
        <p class="hero-subtitle">发现精彩内容，探索无限可能</p>
        <div class="hero-search">
          <el-input
            id="video-center-search"
            name="videoSearch"
            v-model="searchQuery"
            placeholder="搜索视频、分类、标签..."
            size="large"
            @keyup.enter="handleSearch"
            @input="handleSearchInput"
          >
            <template #prefix>
              <el-icon><Search /></el-icon>
            </template>
            <template #suffix>
              <el-button type="primary" @click="handleSearch">
                <el-icon><Search /></el-icon>
              </el-button>
            </template>
          </el-input>
        </div>
      </div>
    </div>

    <!-- 高级筛选器 -->
    <div class="filter-section">
      <div class="filter-container">
        <div class="filter-group">
          <label>分类筛选</label>
          <el-select v-model="selectedCategory" placeholder="选择分类" @change="applyFilters">
            <el-option label="全部" value=""></el-option>
            <el-option 
              v-for="category in categories" 
              :key="category.id" 
              :label="category.name" 
              :value="category.id"
            />
          </el-select>
        </div>
        
        <div class="filter-group">
          <label>排序方式</label>
          <el-select v-model="sortBy" @change="applyFilters">
            <el-option label="最热门" value="views"></el-option>
            <el-option label="最新发布" value="created_at"></el-option>
            <el-option label="最多点赞" value="likes"></el-option>
            <el-option label="评分最高" value="rating"></el-option>
          </el-select>
        </div>
        
        <div class="filter-group">
          <label>时长筛选</label>
          <el-select v-model="durationFilter" @change="applyFilters">
            <el-option label="全部时长" value=""></el-option>
            <el-option label="短视频 (< 10分钟)" value="short"></el-option>
            <el-option label="中等长度 (10-30分钟)" value="medium"></el-option>
            <el-option label="长视频 (> 30分钟)" value="long"></el-option>
          </el-select>
        </div>
        
        <div class="filter-group">
          <label>质量筛选</label>
          <el-select v-model="qualityFilter" @change="applyFilters">
            <el-option label="全部质量" value=""></el-option>
            <el-option label="高清 (HD)" value="hd"></el-option>
            <el-option label="超高清 (4K)" value="4k"></el-option>
          </el-select>
        </div>
        
        <div class="filter-actions">
          <el-button @click="resetFilters">重置筛选</el-button>
          <el-button type="primary" @click="applyFilters">应用筛选</el-button>
        </div>
      </div>
    </div>

    <!-- 热门标签 -->
    <div class="tags-section">
      <h3>热门标签</h3>
      <div class="tags-container">
        <el-tag
          v-for="tag in hotTags"
          :key="tag"
          :type="getTagType(tag)"
          @click="toggleTag(tag)"
          class="tag-item"
        >
          {{ tag }}
        </el-tag>
      </div>
    </div>

    <!-- 智能推荐 -->
    <div class="recommendation-section">
      <h3>为您推荐</h3>
      <div class="recommendation-grid">
        <div 
          v-for="video in recommendedVideos" 
          :key="video.id"
          class="recommendation-card"
          @click="goToDetail(video.id)"
        >
          <div class="card-image">
            <img :src="video.thumbnail" :alt="video.title" />
            <div class="play-overlay">
              <el-icon><CaretRight /></el-icon>
            </div>
            <div class="duration-badge">{{ video.duration }}</div>
          </div>
          <div class="card-content">
            <h4 class="card-title">{{ video.title }}</h4>
            <p class="card-description">{{ video.description }}</p>
            <div class="card-meta">
              <span class="views">{{ formatViews(video.views) }} 次观看</span>
              <span class="likes">{{ video.likes }} 点赞</span>
              <span class="category">{{ video.category?.name || '未分类' }}</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 视频网格 -->
    <div class="videos-section">
      <div class="section-header">
        <h3>精选视频</h3>
        <div class="view-options">
          <el-button-group>
            <el-button 
              :type="viewMode === 'grid' ? 'primary' : 'default'" 
              @click="viewMode = 'grid'"
            >
              <el-icon><Grid /></el-icon>
            </el-button>
            <el-button 
              :type="viewMode === 'list' ? 'primary' : 'default'" 
              @click="viewMode = 'list'"
            >
              <el-icon><List /></el-icon>
            </el-button>
          </el-button-group>
        </div>
      </div>
      
      <div v-if="loading" class="loading-container">
        <el-skeleton :rows="6" animated />
      </div>
      
      <div v-else-if="videos.length === 0" class="empty-state">
        <el-empty description="暂无视频数据">
          <el-button type="primary" @click="resetFilters">重新筛选</el-button>
        </el-empty>
      </div>
      
      <div v-else :class="['videos-container', viewMode]">
        <div 
          v-for="video in videos" 
          :key="video.id"
          class="video-card"
          @click="goToDetail(video.id)"
        >
          <div class="video-thumbnail">
            <img :src="video.thumbnail" :alt="video.title" />
            <div class="play-overlay">
              <el-icon><CaretRight /></el-icon>
            </div>
            <div class="duration-badge">{{ video.duration }}</div>
            <div class="quality-badge" v-if="video.quality">HD</div>
          </div>
          <div class="video-info">
            <h4 class="video-title">{{ video.title }}</h4>
            <p class="video-description">{{ video.description }}</p>
            <div class="video-meta">
              <div class="meta-left">
                <span class="views">{{ formatViews(video.views) }}</span>
                <span class="likes">{{ video.likes }}</span>
                <span class="date">{{ formatDate(video.created_at) }}</span>
              </div>
              <div class="meta-right">
                <span class="category">{{ video.category?.name || '未分类' }}</span>
              </div>
            </div>
            <div class="video-stats">
              <el-progress 
                :percentage="getVideoRating(video)" 
                :show-text="false" 
                :stroke-width="4"
              />
              <span class="rating">{{ getVideoRating(video) }}%</span>
            </div>
          </div>
        </div>
      </div>
      
      <!-- 分页 -->
      <div class="pagination-container">
        <el-pagination
          :current-page="currentPage"
          :page-size="pageSize"
          :total="totalVideos"
          :page-sizes="[12, 24, 48, 96]"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handlePageChange"
        />
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, onMounted, watch } from 'vue'
import { useRouter } from 'vue-router'
import { 
  ElInput, 
  ElButton, 
  ElSelect, 
  ElOption, 
  ElTag, 
  ElIcon, 
  ElSkeleton, 
  ElEmpty, 
  ElProgress, 
  ElPagination,
  ElButtonGroup
} from 'element-plus'
import { 
  Search, 
  CaretRight, 
  Grid, 
  List 
} from '@element-plus/icons-vue'
import AOS from 'aos'
import 'aos/dist/aos.css'
import api from '@/utils/axios'

const router = useRouter()

// 响应式数据
const searchQuery = ref('')
const selectedCategory = ref('')
const sortBy = ref('views')
const durationFilter = ref('')
const qualityFilter = ref('')
const selectedTags = ref([])
const viewMode = ref('grid')
const loading = ref(false)
const videos = ref([])
const categories = ref([])
const recommendedVideos = ref([])
const currentPage = ref(1)
const pageSize = ref(12)
const totalVideos = ref(0)

// 热门标签
const hotTags = ref([
  '动作', '喜剧', '科幻', '爱情', '恐怖', '悬疑', 
  '冒险', '动画', '纪录片', '音乐', '体育', '教育'
])

// 计算属性
const totalPages = computed(() => Math.ceil(totalVideos.value / pageSize.value))

// 加载分类数据
const loadCategories = async () => {
  try {
    const response = await api.get('/admin/categories')
    if (response.success) {
      categories.value = response.data
    }
  } catch (error) {
    console.error('加载分类失败:', error)
  }
}

// 加载推荐视频
const loadRecommendedVideos = async () => {
  try {
    const response = await api.get('/videos/recommended')
    if (response.success) {
      recommendedVideos.value = response.data.slice(0, 6)
    }
  } catch (error) {
    console.error('加载推荐视频失败:', error)
  }
}

// 加载视频数据
const loadVideos = async () => {
  try {
    loading.value = true
    const params = {
      sort_by: sortBy.value,
      order: 'desc',
      page: currentPage.value,
      per_page: pageSize.value
    }
    
    if (selectedCategory.value) {
      params.category_id = selectedCategory.value
    }
    
    if (searchQuery.value) {
      params.search = searchQuery.value
    }
    
    const response = await api.get('/videos', { params })
    if (response.success) {
      videos.value = response.data.data.map(video => ({
        ...video,
        category: video.category?.name || '未分类',
        quality: Math.random() > 0.7 ? 'hd' : 'sd' // 模拟质量数据
      }))
      totalVideos.value = response.data.total
    }
  } catch (error) {
    console.error('加载视频失败:', error)
  } finally {
    loading.value = false
  }
}

// 搜索处理
const handleSearch = () => {
  currentPage.value = 1
  loadVideos()
}

const handleSearchInput = () => {
  // 防抖搜索
  clearTimeout(searchTimeout)
  searchTimeout = setTimeout(() => {
    if (searchQuery.value.length > 2) {
      handleSearch()
    }
  }, 500)
}

let searchTimeout = null

// 标签切换
const toggleTag = (tag) => {
  const index = selectedTags.value.indexOf(tag)
  if (index > -1) {
    selectedTags.value.splice(index, 1)
  } else {
    selectedTags.value.push(tag)
  }
  applyFilters()
}

// 获取标签类型
const getTagType = (tag) => {
  return selectedTags.value.includes(tag) ? 'primary' : 'info'
}

// 应用筛选
const applyFilters = () => {
  currentPage.value = 1
  loadVideos()
}

// 重置筛选
const resetFilters = () => {
  selectedCategory.value = ''
  sortBy.value = 'views'
  durationFilter.value = ''
  qualityFilter.value = ''
  selectedTags.value = []
  searchQuery.value = ''
  currentPage.value = 1
  loadVideos()
}

// 分页处理
const handlePageChange = (page) => {
  currentPage.value = page
  loadVideos()
}

const handleSizeChange = (size) => {
  pageSize.value = size
  currentPage.value = 1
  loadVideos()
}

// 工具函数
const formatViews = (views) => {
  if (views >= 10000) {
    return (views / 10000).toFixed(1) + '万'
  }
  return views.toString()
}

const formatDate = (date) => {
  return new Date(date).toLocaleDateString('zh-CN')
}

const getVideoRating = (video) => {
  // 基于播放量和点赞数计算评分
  const rating = Math.min(100, Math.round((video.likes / video.views) * 1000))
  return Math.max(60, rating) // 最低60分
}

// 跳转到详情页
const goToDetail = (id) => {
  router.push(`/detail/${id}`)
}

// 监听筛选条件变化
watch([selectedCategory, sortBy, durationFilter, qualityFilter], () => {
  applyFilters()
})

onMounted(() => {
  AOS.init({
    duration: 1000,
    easing: 'ease-in-out'
  })
  loadCategories()
  loadRecommendedVideos()
  loadVideos()
})
</script>

<style scoped>
.video-center {
  width: 100vw;
  max-width: none;
  min-height: 100vh;
  background: #ffffff;
  margin: 0;
  padding: 0;
}

/* 顶部横幅 */
.hero-section {
  padding: 80px 0 60px;
  text-align: center;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid #e5e7eb;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="%23667eea" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="%23667eea" opacity="0.1"/><circle cx="50" cy="10" r="0.5" fill="%23667eea" opacity="0.1"/><circle cx="10" cy="60" r="0.5" fill="%23667eea" opacity="0.1"/><circle cx="90" cy="40" r="0.5" fill="%23667eea" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  opacity: 0.3;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 20px;
}

.hero-title {
  font-size: 3.5rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 1rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.hero-subtitle {
  font-size: 1.25rem;
  color: #6b7280;
  margin-bottom: 2rem;
}

.hero-search {
  max-width: 600px;
  margin: 0 auto;
}

.hero-search .el-input {
  border-radius: 50px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* 高级筛选器 */
.filter-section {
  background: white;
  padding: 2rem 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.filter-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  gap: 2rem;
  align-items: end;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 150px;
}

.filter-group label {
  font-weight: 600;
  color: #333;
  font-size: 0.9rem;
}

.filter-actions {
  display: flex;
  gap: 1rem;
  margin-left: auto;
}

/* 热门标签 */
.tags-section {
  background: #f9fafb;
  padding: 2rem 0;
  border-bottom: 1px solid #e5e7eb;
}

.tags-section h3 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #374151;
  font-size: 1.5rem;
}

.tags-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.tag-item {
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 20px;
  padding: 0.5rem 1rem;
}

.tag-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 智能推荐 */
.recommendation-section {
  background: #ffffff;
  padding: 3rem 0;
  border-bottom: 1px solid #e5e7eb;
}

.recommendation-section h3 {
  text-align: center;
  margin-bottom: 2rem;
  color: #374151;
  font-size: 1.8rem;
}

.recommendation-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
}

.recommendation-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  cursor: pointer;
}

.recommendation-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

/* 视频网格 */
.videos-section {
  background: #f9fafb;
  padding: 3rem 0;
}

.section-header {
  max-width: 1200px;
  margin: 0 auto 2rem;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-header h3 {
  color: #374151;
  font-size: 1.8rem;
  margin: 0;
}

.videos-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.videos-container.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
}

.videos-container.list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.videos-container.list .video-card {
  display: flex;
  flex-direction: row;
  max-width: none;
}

.videos-container.list .video-thumbnail {
  width: 200px;
  height: 120px;
  flex-shrink: 0;
}

.videos-container.list .video-info {
  flex: 1;
  padding: 1rem;
}

/* 视频卡片 */
.video-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  cursor: pointer;
}

.video-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.video-thumbnail {
  position: relative;
  width: 100%;
  height: 160px;
  overflow: hidden;
}

.video-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.video-card:hover .video-thumbnail img {
  transform: scale(1.05);
}

.play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.video-card:hover .play-overlay {
  opacity: 1;
}

.duration-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.quality-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #ff4757;
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

.video-info {
  padding: 1rem;
}

.video-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 0.5rem 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-description {
  font-size: 0.9rem;
  color: #6b7280;
  margin: 0 0 1rem 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

.meta-left {
  display: flex;
  gap: 1rem;
}

.meta-right .category {
  background: #e0e7ff;
  color: #667eea;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
}

.video-stats {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.video-stats .el-progress {
  flex: 1;
}

.rating {
  font-size: 0.8rem;
  color: #6b7280;
  font-weight: 600;
}

/* 推荐卡片 */
.recommendation-card .card-image {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
}

.recommendation-card .card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recommendation-card .card-content {
  padding: 1.5rem;
}

.recommendation-card .card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 0.75rem 0;
  line-height: 1.4;
}

.recommendation-card .card-description {
  font-size: 0.9rem;
  color: #6b7280;
  margin: 0 0 1rem 0;
  line-height: 1.5;
}

.recommendation-card .card-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

/* 加载和空状态 */
.loading-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 20px;
}

.empty-state {
  text-align: center;
  padding: 4rem 20px;
}

/* 分页 */
.pagination-container {
  max-width: 1200px;
  margin: 2rem auto 0;
  padding: 0 20px;
  display: flex;
  justify-content: center;
}

/* 响应式设计 - 优化版本 */
@media (min-width: 1920px) {
  .hero-title {
    font-size: 3.5rem;
  }
  
  .hero-subtitle {
    font-size: 1.25rem;
  }
  
  .content-wrapper {
    padding: 0 80px;
  }
  
  .videos-container.grid {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  }
  
  .recommendation-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

@media (min-width: 1600px) {
  .hero-title {
    font-size: 3.25rem;
  }
  
  .hero-subtitle {
    font-size: 1.125rem;
  }
  
  .content-wrapper {
    padding: 0 60px;
  }
  
  .videos-container.grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
  
  .recommendation-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (min-width: 1400px) {
  .hero-title {
    font-size: 3rem;
  }
  
  .hero-subtitle {
    font-size: 1rem;
  }
  
  .content-wrapper {
    padding: 0 50px;
  }
  
  .videos-container.grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
  
  .recommendation-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

@media (min-width: 1200px) {
  .hero-title {
    font-size: 2.75rem;
  }
  
  .hero-subtitle {
    font-size: 0.95rem;
  }
  
  .content-wrapper {
    padding: 0 40px;
  }
  
  .videos-container.grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
  
  .recommendation-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (min-width: 992px) {
  .hero-title {
    font-size: 2.5rem;
  }
  
  .hero-subtitle {
    font-size: 0.9rem;
  }
  
  .content-wrapper {
    padding: 0 30px;
  }
  
  .videos-container.grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
  
  .recommendation-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (min-width: 768px) {
  .hero-title {
    font-size: 2.25rem;
  }
  
  .hero-subtitle {
    font-size: 0.85rem;
  }
  
  .content-wrapper {
    padding: 0 25px;
  }
  
  .videos-container.grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
  
  .recommendation-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

@media (min-width: 576px) {
  .hero-title {
    font-size: 2rem;
  }
  
  .hero-subtitle {
    font-size: 0.8rem;
  }
  
  .content-wrapper {
    padding: 0 20px;
  }
  
  .videos-container.grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
  
  .recommendation-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

@media (max-width: 575px) {
  .hero-title {
    font-size: 1.75rem;
  }
  
  .hero-subtitle {
    font-size: 0.75rem;
  }
  
  .content-wrapper {
    padding: 0 15px;
  }
  
  .videos-container.grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
  
  .recommendation-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  
  .filter-container {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-actions {
    margin-left: 0;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 1.5rem;
  }
  
  .hero-subtitle {
    font-size: 0.7rem;
  }
  
  .content-wrapper {
    padding: 0 12px;
  }
  
  .videos-container.grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
  
  .recommendation-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  
  .tags-container {
    justify-content: flex-start;
  }
  
  .tag-item {
    padding: 4px 8px;
    font-size: 12px;
  }
}
</style>
